package doctor

import (
	"github.com/bgmp/config"
	"github.com/bgmp/handler"
	"github.com/bgmp/model"
	"github.com/gin-gonic/gin"
)

func (b Base) GetPatientDetail(c *gin.Context, req *GetPatientDetailRequest) *GetPatientDetailResponse {
	u := &model.User{}
	u.ID = req.PatientId
	err := u.Get(config.DB)
	if err != nil {
		handler.Errorf(c, "用户不存在")
		return nil
	}
	detail := model.UserDetail{}
	detail.UserId = req.PatientId
	err = detail.GetByUserId(config.DB)
	if err != nil {
		handler.Errorf(c, err.Error())
		return nil
	}
	return &GetPatientDetailResponse{
		UserVO:     *u.GetUserVO(),
		UserDetail: detail,
	}
}

type GetPatientDetailRequest struct {
	PatientId uint `json:"patient_id"`
}

type GetPatientDetailResponse struct {
	model.UserVO

	model.UserDetail
}
